<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id = "parent">
        <p id = "one">hello world</p>
    </div>
    <script>
        var parent = document.getElementById("parent");
        var one = document.getElementById("one");
        var p = document.createElement("p");//添加一个p标签
        p.textContent = "first";
        // var txt = document.createTextNode("first");//给txt添加内容为first
        // parent.appendChild(p);//在p标签里面添加文本元素txt
        console.log(p);
        parent.insertBefore(p,one);//在parent里面的one之前添加这个p标签

    </script>
</body>
</html>